<?php
use yii\helpers\Url;
use yii\web\View;
// use yii\Web\View;
use app\assets\NewCreativeAsset;
NewCreativeAsset::register($this);
$this->title = $this->context->pageTitle.Yii::$app->params['titleSuffix'];
$this->params['breadcrumbs'] = [
  [
    'label' => \Yii::t('creative', 'Creative'),
    'url' => ['creative-list']
  ],
  \Yii::t('creative', 'Edit Custom Creative')
];
$jsMsgs = $this->context->loadJsMsgs([
  'creativeForm'
]);
$this->registerJs("VAM.setVar('LANGUAGE_JS', '".$jsMsgs."');", View::POS_HEAD);
?>
<div class="page-header">
  <h1>
    <?=\Yii::t('creative', 'Creative')?>
    <small><?=\Yii::t('creative', 'Edit Custom Creative')?></small>
  </h1>
</div>
<div class="panel panel-default">
  <div class="panel-heading">
    <i class="fa fa-plus-circle"></i>
    <?=\Yii::t('creative', 'Edit Custom Creative')?>
    <ul class="list-unstyled pull-right">
      <li>
        <a href="#">
          <i class="fa fa-chevron-up"></i>
        </a>
      </li>
    </ul>
  </div>
  <div class="panel-body">
    <div class="row">
      <div class="col-sm-8 col-sm-offset-2">
        <form class="form-horizontal" id="data-frm" method="POST" action="<?= Url::to(['creative/edit-custom-creative-handle']);?>">
          <input class="hidden" type="text" name="id" value="<?=$creative['id']?>">
          <fieldset>
            <legend><?=\Yii::t('creative', 'Creative Info')?></legend>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="creative_name" >
                <em>*</em>
                <?=\Yii::t('creative', 'Creative Name')?>：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="creative_name" type="text" name="name" value="<?=$creative['name']?>" placeholder="<?=\Yii::t('creative', 'Creative Name')?>">
                <div class="help-block text-error" id="creative_name_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="creative_type" >
                <em>*</em>
                <?=\Yii::t('creative', 'Creative Type')?>：
              </label>
              <div class="col-md-7">
                <select class="form-control" id="creative_type" name="type">
				  <option value="0" <?php if ($creative['type'] == 0) echo 'selected';?>>Banner</option>
                  <option value="5" <?php if ($creative['type'] == 5) echo 'selected';?>>WAP</option>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="creative_vocation_large" >
                <em>*</em>
                <?=\Yii::t('creative', 'Vocation')?>：
              </label>
              <div class="col-sm-3">
                <select class="form-control" id="creative_vocation_large" name="parent_category">
                </select>
              </div>
              <div class="col-md-3">
                <select class="form-control" id="creative_vocation_small" name="category">
                </select>
              </div>
            </div>
            <div class="form-group hidden" >
              <label class="col-sm-3 control-label" for="dynamic_creative_flag" >
                <em>*</em>
                <?=\Yii::t('creative', 'Dynamic')?>：
              </label>
              <div class="col-sm-7">
                <label class="radio-inline">
                  <input type="radio" name="is_static" value="1" checked> <?=\Yii::t('creative', 'no')?>
                </label>
                <label class="radio-inline">
                  <input type="radio" name="is_static" value="0"> <?=\Yii::t('creative', 'yes')?>
                </label>
                <div class="help-block"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="landing_page_url">
                <em>*</em>
                <?=\Yii::t('creative', 'Audit Domain')?>：：
              </label>
              <div class="col-sm-7">
                <input class="form-control" id="audit_domain" type="text" name="adomain_list" value="<?=$creative['adomain_list']?>" placeholder="example.com">
                <div class="help-block text-error" id="audit_domain_err"></div>
              </div>
            </div>
           <!--  <div class="form-group">
              <label for="belong_creative" class="col-sm-3 control-label">
                <?=\Yii::t('creative', 'Template')?>：
              </label>
              <div class="col-sm-7">
                <select class="form-control" id="belong_creative" name="template_id" placeholder="<?=\Yii::t('creative', 'Template')?>">
                  <?php 
                    foreach($templates as $template) {
                      $id = $template['id'];
                      $name = $template['name'];
                      echo "<option value='$id'>$name</option>";
                    }
                  ?>
                </select>
              </div>
            </div> -->
            <div class="form-group">
              <label class="col-sm-3 control-label" for="alternative_creative_size">
                <?=\Yii::t('creative', 'Custom Creative Size')?>：
              </label>
              <label class="control-label col-md-1 pr0">
                  <em>*</em>
                  <?=\Yii::t('creative', 'Width')?>：
                </label>
              <div class="col-md-2 pl0">
                <input class="form-control" type="text" id="custom_creative_width" value="<?=$creative['width']?>" name="width" autocomplete="off">
                <div class="help-block text-error" id="custom_creative_width_err"></div>
              </div>
              <label class="control-label col-md-1 pr0">
                <em>*</em>
                <?=\Yii::t('creative', 'Height')?>：
              </label>
              <div class="col-md-2 pl0">
                <input class="form-control" type="text" id="custom_creative_height" value="<?=$creative['height']?>" name="height" autocomplete="off">
                <div class="help-block text-error" id="custom_creative_height_err"></div>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-3 control-label" for="custom_creative_code">
                <em>*</em>
                <?=\Yii::t('creative', 'Custom Creaitve Code')?>：
              </label>
              <div class="col-sm-7">
                <textarea class="form-control" id="custom_creative_code" name="custom_code" cols="30" rows="10" placeholder="<?=\Yii::t('creative', 'Custom Creaitve Code')?>..."><?=$creative['custom_code']?></textarea>
                <div class="help-block text-error" id="custom_creative_code_err"></div>
              </div>
            </div>
          </fieldset>
          <fieldset>
            <div class="form-group">
              <div class="col-sm-offset-3 col-sm-7">
                <div class="btn-form-group pull-right">
                  <input class="operate-type" type="hidden" name="operate_type" value="save">
                  <button type="submit" class="btn btn-primary" data-loading-text="<i class='fa fa-spinner fa-spin'></i> <?=\Yii::t('common', 'Saving')?>..."><?=\Yii::t('common', 'Save')?></button>
                  <a href="<?php echo Url::to(['creative/creative-list']); ?>" class="btn btn-default"><?=\Yii::t('common', 'Back')?></a>
                </div>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>
<?php
  $creativeVocation = $categories;
  $this->registerJs("VAM.setVar('CREATIVE_VOCATION','$creativeVocation')", View::POS_HEAD);

  $parentCategory = array_shift($category);
  $childCategory = array_shift($category);
  $this->registerJs("VAM.setVar('parent_category','$parentCategory')", View::POS_HEAD);
  $this->registerJs("VAM.setVar('child_category','$childCategory')", View::POS_HEAD);
?>
<script type="text/javascript" >
  requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/site.js"], function(common) {
    requirejs(["<?= Yii::getAlias('@web/').Yii::$app->params['envDir'];?>/js/creative/newCustomCreative.js"]);
  });
</script>